﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using Newtonsoft.Json.Serialization;
using Sustainalytics.Utils.WebApi.Filters;

namespace Sustainalytics.ClientWebsites.Service
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            //use camel case for json not default pascal case from .NET
            var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Filters.Add(new CacheabilityActionFilterAttribute());
            //all routing will be done through route attributes inside controllers
            config.MapHttpAttributeRoutes();

#if !DEBUG
            // Force HTTPS on entire API
            config.Filters.Add(new RequireHttpsAttribute());
#endif

        }
    }
}
